home *** CD-ROM | disk | FTP | other *** search
- /** @file
- *
- * VBox Remote Desktop Protocol:
- * External Authentication Library:
- * Windows Logon Authentication.
- */
-
- /*
- * Copyright (C) 2006-2007 innotek GmbH
- *
- * innotek GmbH confidential
- * All rights reserved
- */
-
- /* If defined, debug messages will be written to the specified file. */
- // #define VRDPAUTH_DEBUG_FILE_NAME "\\VRDPAuth.log"
-
- #include <stdio.h>
- #include <string.h>
-
- #include <Windows.h>
-
- #include <VBox/VRDPAuth.h>
-
- static void dprintf(const char *fmt, ...)
- {
- va_list va;
-
- va_start(va, fmt);
-
- char buffer[1024];
-
- _vsnprintf (buffer, sizeof (buffer), fmt, va);
-
- OutputDebugStringA(buffer);
-
- #ifdef VRDPAUTH_DEBUG_FILE_NAME
- FILE *f = fopen (VRDPAUTH_DEBUG_FILE_NAME, "ab");
- fprintf (f, "%s", buffer);
- fclose (f);
- #endif
-
- va_end (va);
- }
-
- extern "C"
- #if defined(_MSC_VER)
- __declspec(dllexport)
- #endif
- VRDPAuthResult VRDPAUTHCALL VRDPAuth (PVRDPAUTHUUID pUuid,
- VRDPAuthGuestJudgement guestJudgement,
- const char *szUser,
- const char *szPassword,
- const char *szDomain)
- {
- VRDPAuthResult result = VRDPAuthAccessDenied;
-
- LPTSTR lpszUsername = (char *)szUser;
- LPTSTR lpszDomain = (char *)szDomain;
- LPTSTR lpszPassword = (char *)szPassword;
-
- /* LOGON32_LOGON_INTERACTIVE is intended for users who will be interactively using the computer,
- * such as a user being logged on by a terminal server, remote shell, or similar process.
- */
- DWORD dwLogonType = LOGON32_LOGON_INTERACTIVE;
- DWORD dwLogonProvider = LOGON32_PROVIDER_DEFAULT;
-
- HANDLE hToken;
-
- dprintf("u[%s], d[%s], p[%s]\n", lpszUsername, lpszDomain, lpszPassword);
-
- BOOL fSuccess = LogonUser(lpszUsername,
- lpszDomain,
- lpszPassword,
- dwLogonType,
- dwLogonProvider,
- &hToken);
-
- if (fSuccess)
- {
- dprintf("LogonUser success. hToken = %p\n", hToken);
-
- result = VRDPAuthAccessGranted;
-
- CloseHandle (hToken);
- }
- else
- {
- dprintf("LogonUser failed %08X\n", GetLastError ());
- }
-
- return result;
- }
-
- /* Verify the function prototype. */
- static PVRDPAUTHENTRY gpfnAuthEntry = VRDPAuth;
-